#lang racket

(define (element-of-set? x set)
  (cond ((null? set) false)
        ((equal? x (car set)) true)
        (else (element-of-set? x (cdr set)))))

(define (adjoin-set x set)
  (cons x set))

(define (union-set set1 set2)
  (append set1 set2))

(define (delete-element-of-set x set)
  (cond ((null? set) '())
        ((equal? (car set) x) (cdr set))
        (else (cons (car set) (delete-element-of-set x (cdr set))))))

(define (intersection-set set1 set2)
  (cond ((null? set1) '())
        ((element-of-set? (car set1) set2)
         (cons (car set1) 
               (intersection-set (cdr set1) 
                                 (delete-element-of-set (car set1) set2))))
        (else (intersection-set (cdr set1) set2))))

(intersection-set (list 1 1 3 4 4) (list 1 2 3 4 4))